class Admin::ArticleCategoriesController < Admin::ApplicationController
  before_action :set_article_category, only: [:show, :edit, :update, :destroy]

  # GET /admin/article_categories
  def index
    @article_categories = ArticleCategory.all
  end

  # GET /admin/article_categories/1
  def show
  end

  # GET /admin/article_categories/new
  def new
    @article_category = ArticleCategory.new(admin_user_id: current_admin_user_id, company_id: current_company_id)
  end

  # GET /admin/article_categories/1/edit
  def edit
  end

  # POST /admin/article_categories
  def create
    @article_category = ArticleCategory.new(article_category_params)

    if @article_category.save
      redirect_to [:admin, @article_category], notice: 'Article category was successfully created.'
    else
      render :new
    end
  end

  # PATCH/PUT /admin/article_categories/1
  def update
    if @article_category.update(article_category_params)
      redirect_to [:admin, @article_category], notice: 'Article category was successfully updated.'
    else
      render :edit
    end
  end

  # DELETE /admin/article_categories/1
  def destroy
    @article_category.destroy
    redirect_to admin_article_categories_url, notice: 'Article category was successfully destroyed.'
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_article_category
      @article_category = ArticleCategory.find(params[:id])
    end

    # Only allow a trusted parameter "white list" through.
    def article_category_params
      params.require(:article_category).permit(:title, :admin_user_id, :company_id, :cate_type)
    end
end
